package com.earthquake.monitor_system.dao;

import com.earthquake.monitor_system.controller.resultType.Pagination;
import com.earthquake.monitor_system.domain.SeismicInformation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SeismicInformationDao {
@Insert("INSERT into seismic_information(earthquake_magnitude, time, latitude, longitude, depth, location,timestamp) value (#{earthquake_magnitude},#{time},#{latitude},#{longitude},#{depth},#{location},#{timestamp})")
    public Boolean insert(SeismicInformation seismicInformationList);
@Select("select * from seismic_information where timestamp = #{timestamp} ")
    public SeismicInformation queryTimestampEq(String timestamp);
@Select("SELECT * FROM ( SELECT * FROM seismic_information order by timestamp DESC ) as li where  status = 0 LIMIT #{startIndex}, #{pageSize} ")
    public List<SeismicInformation> querySeismicInfoList(Map<String,Integer> map);
@Select("select count(*) from seismic_information where  status = 0")
    public String getSeismicInfoCount();
//@Select("select id, earthquake_magnitude, time, latitude, longitude, depth, location from ( SELECT * FROM seismic_information order by earthquake_magnitude DESC ) as li where timestamp > #{stamp} and  status = 0")
@Select("select id, earthquake_magnitude, time, latitude, longitude, depth, location from seismic_information where timestamp > #{stamp} and  status = 0")
    public List<SeismicInformation> getCoordinatePoint(String stamp);
@Select("select count(id) from seismic_information where earthquake_magnitude >= #{Start} and earthquake_magnitude < #{End} and status = 0")
    public String getEarthquakeMagnitudek(Integer Start,Integer End);
@Update("UPDATE seismic_information SET status=1 WHERE id=#{id}")
    public Boolean deleteById(String id);


}